<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box" data-id="10">
        自定义属性
    </div>

    <script>
        let box = document.querySelector('.box')
        alert(box.dataset.id)
    </script>
</body>
</html>